/*
 * Copyright 2011 Potix Corporation. All Rights Reserved.
 * 
 * Licensed under the GNU GENERAL PUBLIC LICENSE Version 3 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at:
 * 
 * http://www.gnu.org/licenses/gpl-3.0.txt
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 */
package org.zkoss.xpage.zss.component;

import javax.faces.el.ValueBinding;

import org.zkoss.zk.ui.Component;
import org.zkoss.zss.model.Book;
import org.zkoss.zss.ui.Spreadsheet;
/**
 * zk spreadsheet jsf component in Domino.
 * @author Dennis Chen
 *
 */
public class SpreadsheetBridge extends SpreadsheetBridgeBase {

	private static final long serialVersionUID = 1L;

	public SpreadsheetBridge() {
		super();
		setRendererType("org.zkoss.xpage.spreadsheet");
	}


	
	public void setBook(Object book) {
		if(book instanceof ValueBinding){
			this.setValueBinding("book", (ValueBinding)book);
		}
		throw new UnsupportedOperationException("Please use ValueBinding to set the book");
    }

	public Book getBook() {
		return (Book)states.get("book",getFacesContext(),this);
	}
	
	public Spreadsheet getSpreadsheet(){
		Component comp = getComponent();
		if(comp instanceof Spreadsheet){
			return (Spreadsheet)comp;
		}
		return null;
	}
	

}
